package internationalenergytradingplatform.controller.SupplierController;

import internationalenergytradingplatform.dto.EmployeeDTO;
import internationalenergytradingplatform.dto.EmployeePageQueryDTO;
import internationalenergytradingplatform.result.PageResult;
import internationalenergytradingplatform.result.Result;
import internationalenergytradingplatform.service.SupplierEmployeeService;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/employee")
@CrossOrigin
@Slf4j
public class EmployeeController {

    @Autowired
    SupplierEmployeeService supplierEmployeeService;

    /**
     *
     * @author yingfeng
     * @date 2024/2/29 16:48
    新增员工
     */
    @PostMapping
    public Result addEmployee(@RequestBody EmployeeDTO employeeDTO){
        log.info("新增员工：{}", employeeDTO);
        supplierEmployeeService.addEmployee(employeeDTO);
        return Result.success();
    }

    /**
     *
     * @author yingfeng
     * @date 2024/3/4 17:19
    员工分页查询
     */
    @GetMapping("/paginationQuery")
    public Result<PageResult> pagingToQueryAllEmployees(EmployeePageQueryDTO employeePageQueryDTO){
        log.info("员工分页查询，参数为：{}", employeePageQueryDTO);
        PageResult pageResult = supplierEmployeeService.pageQuery(employeePageQueryDTO);
        return Result.success(pageResult);
    }
}
